package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.util.ApplicablePlatformEnum;
import com.frogs.system.util.ExpandCodeEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

/**
 * 解冻积分请求参数类
 *
 * @author lijian
 * @version 2014年11月5日 - 下午4:29:18
 */
public class UserIntegralBalanceUnfreezeRequest extends Request {
	
	private static final long serialVersionUID = 2521521288118347162L;

	private Integer userId ;
	
	private String orderId;
	
	private Integer consumeIntegral;
	
	private String expandCode;
	
	private Integer applicablePlatformId;

	/** */
	public UserIntegralBalanceUnfreezeRequest() {
	}

	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), -1);
		this.orderId = requestInfo.getParameter(ApiUrlParamEnum.orderId.getParamName());
		this.consumeIntegral = requestInfo.getIntParameter(ApiUrlParamEnum.consumeIntegral.getParamName(), 0);
		this.expandCode = requestInfo.getParameter(ApiUrlParamEnum.expandCode.getParamName(), ExpandCodeEnum.MALL.getId());
		this.applicablePlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.applicablePlatformId.getParamName(), ApplicablePlatformEnum.WEB.getId());

		if( userId < 0) {
			throw new RequestIllegalException("用户ID不能为空");
		}
		if(StringUtil.isEmpty(orderId)) {
			throw new RequestIllegalException("订单号不能为空");
		}
		if(consumeIntegral < 1) {
			throw new RequestIllegalException("非法的积分");
		}
		
	}
	
	public Integer getUserId() {
		return userId;
	}
	
	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public Integer getConsumeIntegral() {
		return consumeIntegral;
	}

	public void setConsumeIntegral(Integer consumeIntegral) {
		this.consumeIntegral = consumeIntegral;
	}

	public String getExpandCode() {
		return expandCode;
	}

	public void setExpandCode(String expandCode) {
		this.expandCode = expandCode;
	}

	public Integer getApplicablePlatformId() {
		return applicablePlatformId;
	}

	public void setApplicablePlatformId(Integer applicablePlatformId) {
		this.applicablePlatformId = applicablePlatformId;
	}

}
